﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using BasicClass;

namespace DealPLC
{
    /// <summary>
    /// SetLocalTime.xaml 的交互逻辑
    /// </summary>
    public partial class SetLocalTime : BaseUCPLC
    {
        #region 初始化
        /// <summary>
        /// 构造函数
        /// </summary>
        public SetLocalTime()
        {
            InitializeComponent();
            NameClass = "SetLocalTime";

            DataContext = ParSetTime.P_I;
        }
        #endregion 初始化

        /// <summary>
        /// baocun
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSaveTime_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ParSetTime.P_I.WriteIni();

                btnSaveTime.RefreshDefaultColor("保存成功", true);
            }
            catch (Exception ex)
            {

            }
        }

        /// <summary>
        /// 设置时间
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSetTime_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string error = "";
                if (ParSetTime.P_I.SetLocalTime(out error))
                {
                    btnSetTime.RefreshDefaultColor("设置成功", true);
                }
                else
                {
                    WinMsgBox.ShowMsgBox(error);
                }
            }
            catch (Exception ex)
            {

            }
        }
    }
}
